'use strict';

import React from 'react';
import { connect } from 'react-redux';
import { Link} from 'react-router';
import * as actions from '../../actions/zhekou1_set_items';
import { Button,Search,Notice,Icon,Dialog,Loading,Tab,Checkbox,Select,Pagination } from 'qnui';
import { Row, Col } from 'qnui/lib/grid';
import Breadcrumb from 'qnui/lib/breadcrumb'
import Step, { Item as StepItem } from 'qnui/lib/step';
import Input from 'qnui/lib/input';
import Radio,{ Group as RadioGroup } from 'qnui/lib/radio';
import SystemDialog from 'components/system-dialog/index';
import './index.scss';
const { Group: CheckboxGroup } = Checkbox;
class Zhekou1SetItems extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
			overlayVisible:false,
            value: null,
			search:"",
			hasTag:false,
			isSelectTag:false,
			refreshDialog:false,
			refreshContent:"",
			zType:"decreaseAmount",
			decreaseAmount:"",
			discountRate:"",
			itemFamily:"onsale",
			// isOnSeal:true,
			selectedItems:[],
			choiced:false,
			selectAll:false,
			doneItems:[],
			doneItemsInPage:[],
			doneItemsCount:0,
			doneItemCurPage:1,
			doneItemPageSize:30,
			isEdit:false,
			activity_id:0
        };
		this.dispatch = this.props.dispatch;
		
	}
	componentWillMount(){
		if(this.props.location.query.activity_id){
			this.setState({isEdit:true});
		}else{
			this.dispatch(actions.clearSetItems());
		}
		
		if(this.props.location.state && this.props.location.state.doneItems){
			const setItems = this.props.location.state.doneItems;
			//const setItems = sessionStorage.getItem("setItems");
			this.dispatch(
				actions.loadSetItemsInSession({
					set_items:setItems
				})
			);
		}
		this.dispatch(
			actions.getItemsOnSale({
				page:this.props.zhekou1_set_items.page,
				pagesize:this.props.zhekou1_set_items.pagesize,
				cids:this.props.zhekou1_set_items.cids,
				q:this.props.zhekou1_set_items.q
			})
		);
		
		this.dispatch(
			actions.getSellerCats({
				nick:window.info.user_nick
			})
		);
	}
	handlePageSizeChange(size){
		switch(this.state.itemFamily){
			case "onsale":
				this.dispatch(
					actions.getItemsOnSale({
						page:1,
						pagesize:size,
						cids:this.props.zhekou1_set_items.cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "indepot":
				this.dispatch(
					actions.getItemsIndepot({
						page:1,
						pagesize:size,
						cids:this.props.zhekou1_set_items.cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "selected":
				let total_results = this.state.selectedItems.length;
				let ids = this.state.selectedItems.slice(0,size);

				this.dispatch(
					actions.getItemsByIds({
						ids:ids.join(","),
						total_results,
						page:1,
						pagesize:size
					})
				);
			break;
		}
	}
	handlePageChange(page){
		switch(this.state.itemFamily){
			case "onsale":
				this.dispatch(
					actions.getItemsOnSale({
						page:page,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:this.props.zhekou1_set_items.cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "indepot":
				this.dispatch(
					actions.getItemsIndepot({
						page:page,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:this.props.zhekou1_set_items.cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "selected":
				let pageSize = this.props.zhekou1_set_items.pagesize;
				let total_results = this.state.selectedItems.length;
				let ids = this.state.selectedItems.slice((page-1)*pageSize,page*pageSize);
				
				this.dispatch(
					actions.getItemsByIds({
						ids:ids.join(","),
						total_results,
						page:page,
						pagesize:this.props.zhekou1_set_items.pagesize
					})
				);
			break;
		}
	}
	handleCatChange(cids){
		switch(this.state.itemFamily){
			case "onsale":
				this.dispatch(
					actions.getItemsOnSale({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "indepot":
				this.dispatch(
					actions.getItemsIndepot({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:cids,
						q:this.props.zhekou1_set_items.q
					})
				);
			break;
			case "selected":
			break;
		}
	}
	handleOnsearch(q){
		switch(this.state.itemFamily){
			case "onsale":
				this.dispatch(
					actions.getItemsOnSale({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:this.props.zhekou1_set_items.cids,
						q:q["key"]
					})
				);
			break;
			case "indepot":
				this.dispatch(
					actions.getItemsIndepot({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:this.props.zhekou1_set_items.cids,
						q:q["key"]
					})
				);
				break;
			case "selected":
			break;
		}
	}
	handleOnsaleChange(val){
		switch(val){
			case "onseal":
				this.setState({"itemFamily":"onseal","choiced":false,selectAll:false});
				this.dispatch(
					actions.getItemsOnSale({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:"",
						q:""
					})
				);
			break;
			case "indepot":
				this.setState({"itemFamily":"indepot","choiced":false,selectAll:false});
				this.dispatch(
					actions.getItemsIndepot({
						page:1,
						pagesize:this.props.zhekou1_set_items.pagesize,
						cids:"",
						q:""
					})
				);
			break;
		}
	}
	handleShowOnlySeleted(val){
		if(val){
			this.setState({"itemFamily":"selected",selectAll:false});
			
			let pageSize = this.props.zhekou1_set_items.pagesize;
			let total_results = this.state.selectedItems.length;
			let ids = this.state.selectedItems.slice(0,pageSize);
				
			if(total_results<=0){
				this.dispatch(
					actions.errDialog({
						message:"您没有选择任何商品",
						loginFalse:false
					})
				);
				return;
			}
			this.dispatch(
				actions.getItemsByIds({
					ids:ids.join(","),
					total_results,
					page:1,
					pagesize:this.props.zhekou1_set_items.pagesize
				})
			);
		}else{
			this.setState({"itemFamily":"onseal",selectAll:false});
			this.dispatch(
				actions.getItemsOnSale({
					page:this.props.zhekou1_set_items.page,
					pagesize:this.props.zhekou1_set_items.pagesize,
					cids:this.props.zhekou1_set_items.cids,
					q:this.props.zhekou1_set_items.q
				})
			);
		}
	}
	_getActivityId(){
		
		let activity_id_in_path = this.props.location.query.activity_id;
		if(activity_id_in_path){
			//当路径中含有活动ID时，直接返回该ID
			return activity_id_in_path;
		}
		
		let activityId = this.props.zhekou1.activityId;
		if(!activityId){
			activityId = sessionStorage.getItem("activityId");
		}
		if(!activityId){
			//没有活动ID，无法添加商品到打折活动
			this.dispatch(
				actions.errDialog({
					message:"抱歉，活动信息丢失，请重新选择，或创建打折活动",
					loginFalse:false
				})
			);
			return;
		}
		return activityId;
	}
	addAllSelectedItemsToActive(){
		const selectedItems = this.state.selectedItems;
		if(selectedItems.length<=0){
			this.dispatch(
				actions.errDialog({
					message:"您没有选择任何商品",
					loginFalse:false
				})
			);
			return;
		}
		
		const activityId = this._getActivityId();
		const ztype = this.state.zType;
		let value = "";
		let type = "";
		switch(ztype){
			case "decreaseAmount" :
				value = this.state.decreaseAmount;
				type = 0;
			break;
			case "discountRate" :
				value = this.state.discountRate;
				type=1;
			break;
		}
		
		selectedItems.forEach((item)=>{
			const itemset = {num_iid:item,activity_id:activityId,promotion_value:value,promotion_type:type,value,ztype};
			this.dispatch(
				actions.setItems(itemset)
			);
			this.dispatch(
				actions.addItemToActive(itemset)
			);
		});
		this.setState({selectedItems:[]});
	}
	addItemsToActive(num_iid){
		const item = {...this.props.zhekou1_set_items.setItems[num_iid],num_iid};
		if(item){
			if(item.status=="done"){
				Dialog.alert({content:"已经加入折扣了哦！"});
				// 已经进行过打折的，不予处理
				return;
			}
			if(!item.ztype){
				Dialog.alert({content:"请设置打折方式！可以直接输入折后价"});
				// 和没有打折方式的，不予处理
				return;
			}
		}
		const activityId = this._getActivityId();
		const type = item.ztype=="decreaseAmount"?0:1;
		this.dispatch(
			actions.addItemToActive({...item,num_iid,activity_id:activityId,promotion_value:item.value,promotion_type:type})
		);
	}
	handleSettedPageSizeChange(pageSize){
		const doneItemsInPage = this.state.doneItems.slice(0,pageSize);
		this.setState({doneItemsInPage,doneItemPageSize:pageSize,doneItemCurPage:1});
	}
	handleSettedPageChange(page){
		const doneItemsInPage = this.state.doneItems.slice(page-1,page*this.state.doneItemPageSize);
		this.setState({doneItemsInPage,doneItemCurPage:page});
	}
	editItemInActive(num_iid){
		const item = {...this.props.zhekou1_set_items.setItems[num_iid],num_iid};
		const activityId = this._getActivityId();
		const type = item.ztype=="decreaseAmount"?0:1;
		this.dispatch(
			actions.editItemInActive({...item,activity_id:activityId,promotion_value:item.value,promotion_type:type})
		);
	}
	changePrice(ztype,item,value){
		if(ztype=="finalPrice"){
			ztype = "decreaseAmount";
			value = (item.price - value);
		}
		let finaPrice = item.price;
		switch(ztype){
			case "decreaseAmount":
				finaPrice = item.price - value;
			break;
			case "discountRate" :
				finaPrice = item.price * (value/10);
			break;
		}
		this.dispatch(
			actions.setItems({...item,ztype,value,finaPrice})
		);
	}
	onCloseSystemDialog(){
		this.setState({"refreshDialog":false,"orderDialog":false});
		this.props.dispatch(actions.closeDialog());
	}
	changeSelectAllItems(checked){
		const items = this.props.zhekou1_set_items.items;
		const setItems = this.props.zhekou1_set_items.setItems;
		const selectedItems = this.state.selectedItems;
		if(checked){
			items.map(item=>{
				if(selectedItems.indexOf(item.num_iid)<0 && (!setItems[item.num_iid] || setItems[item.num_iid].status!="done")){
					selectedItems.push(item.num_iid);
				}
			})
			this.setState({selectedItems:selectedItems,selectAll:true});
		}else{
			items.map(item=>{
				let index = selectedItems.indexOf(item.num_iid);
				selectedItems.splice(index,1);
			});
			this.setState({selectedItems:selectedItems,selectAll:false});
		}
	}
	handleItemOnClick(num_iid){
		let selectItems = this.state.selectedItems;
		let hasItem = selectItems.indexOf(num_iid)
		if(hasItem<0){
			selectItems.push(num_iid);
		}else{
			selectItems.splice(hasItem,1);
		}
		this.setState({selectedItems:selectItems});
	}
	handleTabChange(tabKey){
		switch(tabKey){
			case "2":
				const setItems = this.props.zhekou1_set_items.setItems;
				const doneItems=[];
				for(var i in setItems){
					if(setItems[i].status=="done"){
						doneItems.push(setItems[i]);
					}
				};
				this.setState({doneItems});
			break;
		}
	}
	render() {
		
		const tab1 = <span><Icon type="add" /> 添加商品</span>;
		const tab2 = this.state.isEdit?"":<span><Icon type="edit" /> 修改商品</span>;
		const tab2Display = this.state.isEdit?{display:"none"}:{display:"block"};
		const tab2ExtraContent = this.state.isEdit?<Link to={"/zhekou1_edit_items?activity_id="+this._getActivityId()}><Button shape="ghost">返回当前折扣</Button></Link>:"";
		const steps = this.state.isEdit?"":
					<Step current={1} type="dot">
						<StepItem title="设置活动" />
						<StepItem title="选择商品" />
						<StepItem title="完成"/>
					</Step>;
		const items = this.props.zhekou1_set_items.items;
		const setItems = this.props.zhekou1_set_items.setItems;
		const sellerCats = this.props.zhekou1_set_items.sellerCats;
		const settingAll = items.length>0?"block":"none";
		const noItems = items.length>0?"none":"block";
		const currentPage = this.props.zhekou1_set_items.page;
		const totalItems = parseInt(this.props.zhekou1_set_items.totalResults);
		const pageSize = this.props.zhekou1_set_items.pagesize;
		const doneItems = this.state.doneItems.slice((this.state.doneItemCurPage-1),this.state.doneItemCurPage*this.state.doneItemPageSize);
		const doneItemsCount = this.state.doneItems.length;
		let itemDoneCount = 0;
		for(let key in setItems) 
		{ 
			if(setItems[key].status=="done"){
				itemDoneCount++;
			};
		} 
		return (
		<div>
			<SystemDialog 
				 loginError={this.props.zhekou1_set_items.loginError}
			    creating={this.props.zhekou1_set_items.creating}
			    message={this.props.zhekou1_set_items.message}
			    error={this.props.zhekou1_set_items.error}
				 refreshDialog={this.state.refreshDialog}
				 orderDialog={this.state.orderDialog}
		 		 onCloseDialog={this.onCloseSystemDialog.bind(this)}
				/>
		  <Row style={{background:"#F6F6F6",margin:"3px 0"}} justify="start">
			<Col span="8" align="center">
			<Breadcrumb maxNode={5}>
				  <Breadcrumb.Item>打折活动</Breadcrumb.Item>
				  <Breadcrumb.Item>创建</Breadcrumb.Item>
				  <Breadcrumb.Item>限时折扣</Breadcrumb.Item>
			  </Breadcrumb>
			</Col>
			<Col offset="2">
				{steps}
			</Col>
		  </Row>
		  <Row style={{marginTop:"20px"}}>
			<Tab tabBarExtraContent={tab2ExtraContent}  onChange={this.handleTabChange.bind(this)} defaultActiveKey="1" style={{width:"100%"}} navStyle={{fontSize:"18px"}} contentStyle={{padding:"0"}}>
				<Tab.TabPane tab={tab1} key="1">
				<Row style={{background:"#F6F6F6",margin:"3px 0",lineHeight:"45px"}}>
					<Col span="9">
						<RadioGroup defaultValue="onseal" onChange={this.handleOnsaleChange.bind(this)}>
							<Radio id="onseal" value="onseal">出售中的商品</Radio>
							<Radio id="indepot" value="indepot">仓库中的商品</Radio>
						</RadioGroup>
					</Col>
					<Col span="9" style={{textAlign:"right"}}>
							{/*<Checkbox id="hideother" value="hideother">隐藏其他活动的商品</Checkbox>*/}
							<Checkbox id="choiced" value="choiced" checked={this.state.itemFamily=="selected"} onChange={this.handleShowOnlySeleted.bind(this)}>只显示已选择</Checkbox>
					</Col>
					<Col span="6" style={{textAlign:"right"}}>
						打折<span style={{color:"#FFA033"}}>{itemDoneCount}</span>个，还可以打折<span style={{color:"#FFA033"}}>{150-itemDoneCount}</span>个
					</Col>
				</Row>
				<Row style={{padding:"0"}}>
					<Col span="12">
						 <Select placeholder="类目查找" disabled={this.state.itemFamily=="selected"} autoWidth={true} onChange={this.handleCatChange.bind(this)}>
							<Option value="0">全部</Option>
							 {sellerCats.map((cat)=>{
								 return (<Option key={cat.cid} value={cat.cid}>{cat.name}</Option>);
							 })}
						 </Select>&nbsp;
						 <Search type="normal"  disabled={this.state.itemFamily=="selected"} onSearch={this.handleOnsearch.bind(this)} placeholder="商品标题或链接" />
					</Col>
					<Col span="12">
						 <Pagination current={currentPage} total={totalItems} pageSize={pageSize} pageSizeList={[10,20,30]} pageSizeSelector="dropdown" type="simple" onChange={this.handlePageChange.bind(this)} onPageSizeChange={this.handlePageSizeChange.bind(this)} />
					</Col>
				</Row>
				<Row style={{lineHeight:"45px",marginTop:"10px",textAlign:"center",display:noItems}}>
					没有任何商品
				</Row>
				<Row style={{background:"#F6F6F6",lineHeight:"45px",padding:"0",marginTop:"10px",display:settingAll}}>
					<Col fixedSpan="6">
						<Checkbox checked={this.state.selectAll} onChange={this.changeSelectAllItems.bind(this)}>全选</Checkbox>
					</Col>
					<Col  span="4">
					</Col>
					<Col>
						<div style={{color:"#999",width:"70px",float:"left",textAlign:"right"}}>批量设置</div>&nbsp;
						<Input 
							style={{width:"130px"}}
							size="large" 
							addonBefore="打" 
							state={this.state.zType=="discountRate"?"success":""}
							onClick={()=>{this.setState({zType:"discountRate",decreaseAmount:""});}}
							onChange={(val)=>{this.setState({discountRate:val})}}
							value={this.state.discountRate}
							ref="allDiscountRate"
							addonAfter="折" 
						/>&nbsp;
						<Input 
							style={{width:"130px"}}
							size="large" 
							addonBefore="减"
							state={this.state.zType=="decreaseAmount"?"success":""}
							onClick={()=>{this.setState({zType:"decreaseAmount",discountRate:""});}}
							onChange={(val)=>{this.setState({decreaseAmount:val})}}
							value={this.state.decreaseAmount}
							ref="allDecreaseAmount"
							addonAfter="元" 
						/>
					</Col>
					<Col fixedSpan="5">
						<Button type="primary" onClick={this.addAllSelectedItemsToActive.bind(this)}>批量设置</Button>
					</Col>
				</Row>
				{items.map((item)=>{
					let finaPrice = "";
					if(setItems[item.num_iid]){
						if(setItems[item.num_iid].finaPrice){
							finaPrice = setItems[item.num_iid].finaPrice;
						}else if(setItems[item.num_iid].ztype=="discountRate"){
							finaPrice = item.price*(parseInt(setItems[item.num_iid].value)/10)
						}else{
							finaPrice = item.price-(parseInt(setItems[item.num_iid].value))
						}
					}
					const decreaseAmount = (setItems[item.num_iid] && setItems[item.num_iid].ztype=="decreaseAmount")?setItems[item.num_iid].value:"";
					const discountRate = (setItems[item.num_iid] && setItems[item.num_iid].ztype=="discountRate")?setItems[item.num_iid].value:"";
					const settingDone = (setItems[item.num_iid] && setItems[item.num_iid].status=="done");
					const isSelected = !(this.state.selectedItems.indexOf(item.num_iid)<0);
					return(
						<Row key={item.num_iid} align="center" style={{padding:0,margin:"5px 0",borderBottom:"1px dashed #CCCCCC"}}>
							<Col fixedSpan="1">
								<Checkbox onChange={this.handleItemOnClick.bind(this,item.num_iid)} disabled={settingDone} checked={isSelected} id={item.num_iid} value={item.num_iid}></Checkbox>
							</Col>
							<Col fixedSpan="5">
								<a href={"https://item.taobao.com/item.htm?id="+item.num_iid} target="_blank"><img style={{border:"1px solid #C7C7C7"}} src={item.pic_url+"_80x80q90.jpg_.webp"} /></a>
							</Col>
							<Col span="4">
								<span><a href={"https://item.taobao.com/item.htm?id="+item.num_iid} target="_blank">{item.title}</a></span>
							</Col>
							<Col>
								<div className="price_number" style={{fontWeight:"bold",width:"70px",float:"left",textAlign:"right",lineHeight:"32px"}}>{item.price}</div>&nbsp;
								<Input 
									disabled={settingDone}
									style={{width:"130px"}}
									size="large" 
									addonBefore="打" 
									state={(setItems[item.num_iid] && setItems[item.num_iid].ztype=="discountRate")?"success":""}
									onChange={this.changePrice.bind(this,"discountRate",item)}
									value={discountRate}
									addonAfter="折" 
								/>&nbsp;
								<Input 
									disabled={settingDone}
									style={{width:"130px"}}
									size="large" 
									addonBefore="减"
									state={(setItems[item.num_iid] && setItems[item.num_iid].ztype=="decreaseAmount")?"success":""}
									onChange={this.changePrice.bind(this,"decreaseAmount",item)}
									value={decreaseAmount}
									addonAfter="元" 
								/>&nbsp;
								<Input 
									disabled={settingDone}
									style={{width:"70px"}}
									size="large" 
									placeholder="折后价"
									onChange={this.changePrice.bind(this,"finalPrice",item)}
									value={finaPrice}
								/>
							</Col>
							<Col fixedSpan="5">
								<Button onClick={this.addItemsToActive.bind(this,item.num_iid)}>加入活动</Button>
							</Col>
						</Row>
					)
				})}
				<Row justify="space-around" style={{marginTop:"10px"}}>
						<Link to="zhekou1_list">
							<Button size="large">完成设置</Button>
						</Link>
				</Row>
				</Tab.TabPane>
				<Tab.TabPane tab={tab2} tabStyle={tab2Display} key="2">
					<Row style={{padding:"0",marginTop:"13px"}}>
						<Col span="12">
							{/*
							 <Select placeholder="类目查找" autoWidth={false} onChange={this.handleCatChange.bind(this)}>
									<Option value="yes">常规</Option>
									<Option value="no">无下拉箭头一个很长的类目</Option>
							 </Select>&nbsp;
							 <Search type="normal"  onSearch={()=>{}} placeholder="商品标题或链接" />
							 */}
						</Col>
						<Col span="12">
							 <Pagination current={this.state.doneItemCurPage} total={doneItemsCount} pageSize={this.state.doneItemPageSize} defaultCurrent={1} pageSizeList={[30,80,150]} pageSizeSelector="dropdown" type="simple" onChange={this.handleSettedPageChange.bind(this)} onPageSizeChange={this.handleSettedPageSizeChange.bind(this)} />
						</Col>
					</Row>
					{/*
					<Row style={{background:"#F6F6F6",lineHeight:"45px",padding:"0",marginTop:"10px"}}>
						<Col fixedSpan="6">
							<Checkbox>全选</Checkbox>
						</Col>
						<Col  span="4">
						</Col>
						<Col>
							<div style={{color:"#999",width:"70px",float:"left",textAlign:"right"}}>批量设置</div>&nbsp;
							<Input 
								style={{width:"130px"}}
								size="large" 
								addonBefore="打" 
								state={this.state.zType=="discountRate"?"success":""}
								onClick={()=>{}}
								addonAfter="折" 
							/>&nbsp;
							<Input 
								style={{width:"130px"}}
								size="large" 
								addonBefore="减"
								state={this.state.zType=="decreaseAmount"?"success":""}
								onClick={()=>{}}
								addonAfter="元" 
							/>
						</Col>
						<Col fixedSpan="5">
							<Button type="primary">批量设置</Button>
						</Col>
					</Row>
					*/}
					{doneItems.map((item)=>{
						let finaPrice = "";
						if(setItems[item.num_iid]){
							if(setItems[item.num_iid].finaPrice){
								finaPrice = setItems[item.num_iid].finaPrice;
							}else if(setItems[item.num_iid].ztype=="discountRate"){
								finaPrice = item.price*(parseInt(setItems[item.num_iid].value)/10)
							}else{
								finaPrice = item.price-(parseInt(setItems[item.num_iid].value))
							}
						}
						const decreaseAmount = (setItems[item.num_iid] && setItems[item.num_iid].ztype=="decreaseAmount")?setItems[item.num_iid].value:"";
						const discountRate = (setItems[item.num_iid] && setItems[item.num_iid].ztype=="discountRate")?setItems[item.num_iid].value:"";
						const isSelected = !(this.state.selectedItems.indexOf(item.num_iid)<0);
						let currentItem = "";
						if(this.props.zhekou1_set_items.editItemIid && this.props.zhekou1_set_items.editItemIid==item.num_iid){
							currentItem=<div><Icon type="select" size="small" />修改成功</div>;
						}
						return(
							<Row key={item.num_iid} align="center" style={{padding:0,margin:"5px 0",borderBottom:"1px dashed #CCCCCC"}}>
								<Col fixedSpan="1">
									<Checkbox onChange={this.handleItemOnClick.bind(this,item.num_iid)}  checked={isSelected} id={item.num_iid} value={item.num_iid}></Checkbox>
								</Col>
								<Col fixedSpan="5">
									<a href={"https://item.taobao.com/item.htm?id="+item.num_iid} target="_blank"><img style={{border:"1px solid #C7C7C7"}} src={item.pic_url+"_80x80q90.jpg_.webp"} /></a>
								</Col>
								<Col span="4">
									<span><a href={"https://item.taobao.com/item.htm?id="+item.num_iid} target="_blank">{item.title}</a></span>
								</Col>
								<Col>
									<div className="price_number" style={{fontWeight:"bold",width:"70px",float:"left",textAlign:"right",lineHeight:"32px"}}>{item.price}</div>&nbsp;
									<Input 
										style={{width:"130px"}}
										size="large" 
										addonBefore="打" 
										state={(setItems[item.num_iid] && setItems[item.num_iid].ztype=="discountRate")?"success":""}
										onChange={this.changePrice.bind(this,"discountRate",item)}
										value={discountRate}
										addonAfter="折" 
									/>&nbsp;
									<Input 
										style={{width:"130px"}}
										size="large" 
										addonBefore="减"
										state={(setItems[item.num_iid] && setItems[item.num_iid].ztype=="decreaseAmount")?"success":""}
										onChange={this.changePrice.bind(this,"decreaseAmount",item)}
										value={decreaseAmount}
										addonAfter="元" 
									/>&nbsp;
									<Input 
										style={{width:"70px"}}
										size="large" 
										placeholder="折后价"
										onChange={this.changePrice.bind(this,"finalPrice",item)}
										value={finaPrice}
									/>
								</Col>
								<Col>
								{currentItem}
								</Col>
								<Col fixedSpan="5">
									<Button type="secondary" onClick={this.editItemInActive.bind(this,item.num_iid)}>修改折扣</Button>
								</Col>
							</Row>
						)
					})}
					<Row justify="space-around" style={{marginTop:"10px"}}>
						<Link to="zhekou1_list">
							<Button size="large">完成设置</Button>
						</Link>
					</Row>
				</Tab.TabPane>
			</Tab>
		  </Row>
		</div>
		);
	}
}


export default connect((state)=> {
  return {
    zhekou1_set_items: state.zhekou1_set_items,
	zhekou1:{activityId:state.zhekou1.activityId}
  };
})(Zhekou1SetItems);